<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-06-29 10:18
 * Modified Time: 2019-06-29 10:18
 * Version: 2.0
 */

namespace App\Modules\Order\Repositories;


use App\Models\OrderCommentLike;
use App\Modules\Order\Validators\OrderCommentLikeValidator;
use Flower\Core\Repository\Eloquent\BaseRepository;

class OrderCommentLikeRepository extends BaseRepository
{
	public function model()
	{	
		return OrderCommentLike::class;
	}
	public function validator()
	{
		return OrderCommentLikeValidator::class;
	}


	/**
	 * 点赞
	 * @param $memberId
	 * @param $commentId
	 * @return mixed
	 * @author Happy dong
	 * @modifiedTime 2019-07-31 17:36
	 */
	public function add($memberId,$commentId){
		$data = [
			'member_id' => $memberId,
			'comment_id' => $commentId,
		];
		return $this->firstOrCreate($data);
	}


	/**
	 *  取消点赞
	 * @param $ids
	 * @return int
	 */
	public function deleteById($commentId,$memberId){
		return $this->deleteWhere(['member_id'=>$memberId,'comment_id'=>$commentId]);
	}
}